//
//  UATApi.h
//  Pods-UStarter_Example
//
//  Created by Mark on 2021/1/7.
//

#import <Foundation/Foundation.h>
#import "UATRequestConfig.h"
NS_ASSUME_NONNULL_BEGIN

/// 请求状态回调
typedef NS_ENUM(NSInteger,UATApiRequstStatus) {
    UATApiRequestStatusDOING = 0,
    UATApiRequestStatusSUCCESS = 1,
    UATApiRequestStatusFAIL = 2,
};

/// 请求操作回调
typedef void(^UATApiRequestCallback)(UATApiRequstStatus status,__nullable id responseObjec, NSProgress* _Nullable progress, NSURLSessionDataTask* _Nullable task, NSError* _Nullable error);

@interface UATApi : NSObject



+ (void) doGetAction:(NSString*)action
           withParam:(nullable NSDictionary*)param
            callback:(UATApiRequestCallback)cb;

+ (void) doPostJsonAction:(NSString*)action
                withParam:(nullable NSDictionary*)param
                 withData:(nullable NSDictionary*)data
                 callback:(UATApiRequestCallback)cb;

+ (void) doPostFormDataAction:(NSString*)action
                    withParam:(nullable NSDictionary*)param
                     withData:(NSDictionary*)data
                           cb:(UATApiRequestCallback)cb;

+ (void) doPutAction:(NSString*)action
           withParam:(nullable NSDictionary*)param
            withData:(nullable NSDictionary*)data
            callback:(UATApiRequestCallback)cb;

+ (void) doDeleteAction:(NSString*)action
              withParam:(nullable NSDictionary*)param
               withData:(nullable NSDictionary*)data
               callback:(UATApiRequestCallback)callback;

/// 下载到默认位置
+ (void) downloadAction:(NSString*)action
              withParam:(nullable NSDictionary*)param
                   data:(nullable NSDictionary*)data
                     cb:(UATApiRequestCallback)cb;
/// 下载到指定位置
+ (void) downloadAction:(NSString*)action
              withParam:(nullable NSDictionary*)param
                   data:(nullable NSDictionary*)data
            destination:(NSString*)destination
                     cb:(UATApiRequestCallback)cb;

/// 下载到指定位置并且重命名
+ (void) downloadAction:(NSString*)action
              withParam:(nullable NSDictionary*)param
                   data:(nullable NSDictionary*)data
            destination:(nullable NSString*)destination
                 rename:(nullable NSString*)rename
                     cb:(UATApiRequestCallback)cb;

/// 下载到指定位置【最完整】
+ (void) downloadAction:(NSString *)action
              withParam:(NSDictionary *)param
                   data:(NSDictionary *)data
   searchPathDomainMask:(NSSearchPathDomainMask)searchPathDomainMask
            destination:(nonnull NSString *)destination
                 rename:(nonnull NSString*)rename
                     cb:(UATApiRequestCallback)cb ;

/// 上传文件
+ (void) uploadAction:(NSString*)action
            withParam:(nullable NSDictionary*)param
                 data:(nullable NSDictionary*)data
             fileData:(NSData*)fileData
              fileKey:(NSString*)fileKey
                   cb:(UATApiRequestCallback)cb;



@end

NS_ASSUME_NONNULL_END
